/**
 * 
 */
package megamek.common.actions;

import junit.framework.TestCase;
import megamek.common.Aero;
import megamek.common.Dropship;
import megamek.common.Entity;
import megamek.common.Game;
import megamek.common.IGame;
import megamek.common.Player;

import org.junit.Before;
import org.junit.Test;

/**
 * @author Odessa
 * 
 */
public class PhysicalAttackActionTest extends TestCase
{
	PhysicalAttackAction attack1;
	PhysicalAttackAction attack2;
	IGame game;
	Entity aero;



	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception
	{
		attack1 = new PhysicalAttackAction(1, 1);
		attack2 = new PhysicalAttackAction(1, 1, 1);
		game = new Game();
		aero = new Aero();
	}



	/**
	 * Test method for
	 * {@link megamek.common.actions.PhysicalAttackAction#toHitIsImpossible(megamek.common.IGame, megamek.common.Entity, megamek.common.Targetable)}
	 * .
	 */
	@Test
	public void testToHitIsImpossible()
	{
		String s1 = PhysicalAttackAction.toHitIsImpossible(game, aero, null);
		assertEquals("target is null", s1);
	}



	/**
	 * Test method for
	 * {@link megamek.common.actions.PhysicalAttackAction#toHitIsImpossible(megamek.common.IGame, megamek.common.Entity, megamek.common.Targetable)}
	 * . Tests when the same entity is passed as the target.
	 */
	@Test
	public void testToHitIsImpossible_Friendly()
	{
		String s1 = PhysicalAttackAction.toHitIsImpossible(game, aero, aero);
		assertEquals(
				"A friendly unit can never be the target of a direct attack.",
				s1);
	}



	/**
	 * Test method for
	 * {@link megamek.common.actions.PhysicalAttackAction#toHitIsImpossible(megamek.common.IGame, megamek.common.Entity, megamek.common.Targetable)}
	 * . Tests when the entity and target are on the same team.
	 */
	@Test
	public void testToHitIsImpossible_FriendlySameTeam()
	{
		Entity en = new Aero();
		Player p1 = new Player(1, "Sean");
		Player p2 = new Player(2, "John");

		aero.setOwner(p1);
		en.setOwner(p2);

		aero.getOwner().setTeam(1);
		en.getOwner().setTeam(1);

		String s1 = PhysicalAttackAction.toHitIsImpossible(game, aero, en);
		assertEquals(
				"A friendly unit can never be the target of a direct attack.",
				s1);
	}



	/**
	 * Test method for
	 * {@link megamek.common.actions.PhysicalAttackAction#toHitIsImpossible(megamek.common.IGame, megamek.common.Entity, megamek.common.Targetable)}
	 * . Tests when the entity and target are on the same team.
	 */
	@Test
	public void testToHitIsImpossible_NotInRange()
	{
		Entity en = new Dropship();
		Player p1 = new Player(1, "Sean");
		Player p2 = new Player(2, "John");

		String s1 = PhysicalAttackAction.toHitIsImpossible(game, aero, en);
		System.out.println(s1);
		/*
		 * assertEquals(
		 * "A friendly unit can never be the target of a direct attack.", s1);
		 */

		// if (en.getPosition().distance(target.getPosition()) > 1)
		// return "Target not in range";
	}



	/**
	 * Test method for
	 * {@link megamek.common.actions.PhysicalAttackAction#setCommonModifiers(megamek.common.ToHitData, megamek.common.IGame, megamek.common.Entity, megamek.common.Targetable)}
	 * .
	 */
	@Test
	public void testSetCommonModifiers()
	{
		fail("Not yet implemented");
	}

}
